<template>
	<view class="page">
		<uni-section title="个人简要汇总" type="line"></uni-section>
		<view class="d1_box">
				<text space="emsp" class="text_d1_dd">姓名：{{userIn.username}}</text>
				<text space="emsp" class="text_d1">职级：{{userIn.level}} (级别)</text>
				<text space="emsp" class="text_d1">当前积分：{{userIn.yue_qian}}(分)</text>
				<text space="emsp" class="text_d1">总积分：{{userIn.zong_qian}}(分)</text>
				<!-- <view class="hr"></view> -->
		</view>
		<uni-section title="历史记录" type="line"></uni-section>
		<view class="d2_box" v-for="user in userInList">
			<uni-card class="id_card"
			title="当月退休积分" 
			:extra=user.time
			note="..."
		 	mode="basic"
			is-shadow="true">
				姓名：{{user.username}} </br> 
				职级：{{user.level}} </br> 
				当月积分：{{user.yue_qian}} </br> 
				总积分：{{user.zong_qian}} </br> 
		</uni-card>
		</view>
	</view>
</template>

<script>
	import uniCard from "../../components/uni-card/uni-card.vue"
	import uniSection from '@/components/uni-section/uni-section.vue'
	export default {
		data() {
			return {
				changdu:10,
				userIn:{
					username:'',
					sex:'',
					level:'',
					yue_qian:'',
					zong_qian:''
				},
				userInList:[]
			}
		},
		methods: {
			
		},
		onLoad(e) {
			var me=this;
			uni.showLoading({
			    title: '获取数据中'
			});
			//一。使用js里面的 变量，实现全局变量。
			// var serverUrl=common.serverUrl;
			//二。使用挂载main.js里面的 变量，实现全局变量。
			var serverUrl=me.serverUrl;
			console.log(e);
			 //发起请求
			 uni.request({
			 	url:serverUrl+"/api/user/username",
				data:{
					username:e.username,
					id_ka:e.id_ka
				},
				success(res) {
					console.log("访问成功！");
					console.log(res);
					console.log(res.data.isok);
					me.userIn.username=res.data.sites[0].username;
					me.userIn.sex=res.data.sites[0].sex;
					me.userIn.level=res.data.sites[0].level;
					me.userIn.yue_qian=res.data.sites[0].yue_qian;
					me.userIn.zong_qian=res.data.sites[0].zong_qian;
					uni.hideLoading();
				}
			 });
			 
			 uni.request({
			 	url:serverUrl+"/api/user/usernamelist",
				data:{
					username:e.username,
					id_ka:e.id_ka
				},
				success(res) {
					console.log("list访问成功！");
					console.log(res);
					me.userInList=res.data.sites;
					console.log(me.userInList);
				}
			 })
		},
		components:{
			uniCard,
			uniSection
		}
	}
</script>

<style>
@import url("cy_nianjing_y2.css");
</style>
